import { getCategoryList } from '../../services/goods';

Page({
  data: {
    activeTab: 0,
    tabs: [],
    shopList: [],

  },
  onShow(option) {
    my.setNavigationBar({
      title: '分类',
      backgroundColor: '#4BA3F9'
    })
  },
  handleChange(index) {
    this.setData({
      activeTab: index,
    });
  },
  onChange(index) {
    this.setData({
      activeTab: index,
    });
  },
  onLoad(query) {
    // 页面加载
    this.getCategoryList()
  },

  togoodslist(event) {
    console.log(event)
    my.navigateTo({
      url: '/pages/shopList/shopList?categoryId='+event.target.dataset.categoryId
    })
  },
  async getCategoryList() {
    const { code, data } = await getCategoryList()

    if (code != 0) return false

    this.setData({ tabs: [{ anchor: '分类', title: '分类title', index: 0 }] })

    if (data.list.length > 0) {
      this.setData({
        shopList: data.list,
      })
    }
  },
});
